home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nejlepší hry
/
Nejlepsi hry.iso
/
hry
/
sea of chaos
/
sea_install.msi
/
_15C39AAA7726369D39812BD40F01CF6A
/
_C29F373318B24B5C8B9E9CF69DA18327
< prev
next >
Wrap
Text File
|
2005-08-15
|
1KB
|
52 lines
///impact particle shader
//input should be 4 points that are the same, tex coord will expand them in screen space
//3rd tex coord is rotation amount
//Luke Lenhart
//(C)2004-2005 Digipen Institute of Technology
//world,view,projection transform
float4x4 matViewProj;
//camera position in world space
float4 cameraPos;
//particle size modifier
float size;
//shader input
struct VS_INPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
float3 Tex0 : TEXCOORD0;
};
//shader output
struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
float2 Tex0 : TEXCOORD0;
};
//shader code
VS_OUTPUT VShader(VS_INPUT In)
{
VS_OUTPUT Out;
//transform pos and copy tex coord and color over
Out.Pos=mul(matViewProj,In.Pos);
Out.Tex0=In.Tex0;
Out.Color=In.Color;
//rotate and expand outwards from center point, based on distance and tex coord
float2x2 matRot={cos(In.Tex0.z),sin(In.Tex0.z),-sin(In.Tex0.z),cos(In.Tex0.z)};
float2 posOffset=mul(matRot,In.Tex0.xy-0.5f);
float dist=distance(cameraPos,In.Pos);
Out.Pos.xy+=(1.0f/sqrt(dist))*posOffset*size;
//spit out the results
return Out;
}